import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/personal-race'
    },
    {
      path: '/personal-race',
      name: 'personal-race',
      component: () => import('@/views/PersonalRace.vue'),
      meta: {
        title: '个人赛'
      }
    },
    {
      path: '/video-playback',
      name: 'video-playback',
      component: () => import('@/views/VideoPlayback.vue'),
      meta: {
        title: '视频回放'
      }
    }
  ]
})

// 标题更新
router.beforeEach((to, from, next) => {
  document.title = to.meta.title ? `${to.meta.title} - 轮滑过桩比赛系统` : '轮滑过桩比赛系统'
  next()
})

export default router 